<!DOCTYPE HTML>
<html lang="en" >
    
    <head>
        
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>js数据类型 | 个人笔记</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.6.7">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="../../gitbook/style.css">
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-search/search.css">
        
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    

        
    
    
    <link rel="next" href="../../md/js/js数据类型的转换.html" />
    
    
    <link rel="prev" href="../../md/js/js基础.html" />
    

        
    </head>
    <body>
        
        
    <div class="book"
        data-level="3.1"
        data-chapter-title="js数据类型"
        data-filepath="md/js/js数据类型.md"
        data-basepath="../.."
        data-revision="Fri Jul 27 2018 10:27:46 GMT+0800 (中国标准时间)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
            

            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="../../index.html">
                
                        <i class="fa fa-check"></i>
                        
                        Introduction
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" data-path="md/html/HTML5.html">
            
                
                    <a href="../../md/html/HTML5.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        HTML介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2" data-path="md/css/CSS笔记.html">
            
                
                    <a href="../../md/css/CSS笔记.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        css笔记
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3" data-path="md/js/js基础.html">
            
                
                    <a href="../../md/js/js基础.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.</b>
                        
                        js介绍
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="3.1" data-path="md/js/js数据类型.html">
            
                
                    <a href="../../md/js/js数据类型.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.1.</b>
                        
                        js数据类型
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="md/js/js数据类型的转换.html">
            
                
                    <a href="../../md/js/js数据类型的转换.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.</b>
                        
                        js数据类型的转换
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="md/js/js赋值运算符.html">
            
                
                    <a href="../../md/js/js赋值运算符.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.3.</b>
                        
                        js赋值运算符
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="md/js/js比较运算符.html">
            
                
                    <a href="../../md/js/js比较运算符.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.4.</b>
                        
                        js比较运算符
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4" data-path="md/js/js笔记.html">
            
                
                    <a href="../../md/js/js笔记.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.</b>
                        
                        js大佬de笔记
                    </a>
            
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    Published with GitBook
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../../" >个人笔记</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h3 id="js&#x6570;&#x636E;&#x7C7B;&#x578B;">js&#x6570;&#x636E;&#x7C7B;&#x578B;</h3>
<h3 id="javascript&#x7684;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x6709;&#xFF08;2&#x79CD;&#xFF09;">JavaScript&#x7684;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x6709;&#xFF08;2&#x79CD;&#xFF09;</h3>
<pre><code>&#x7B80;&#x5355;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x548C;&#x590D;&#x6742;&#x6570;&#x636E;&#x7C7B;&#x578B;
</code></pre><h5 id="&#x539F;&#x59CB;&#x7C7B;&#x578B;&#x548C;&#x5F15;&#x7528;&#x7C7B;&#x578B;&#x4ED6;&#x4EEC;&#x7684;&#x50A8;&#x5B58;&#x65B9;&#x5F0F;&#x4E0D;&#x4E00;&#x6837;&#xFF0C;&#x539F;&#x59CB;&#x7C7B;&#x578B;&#x7684;&#x503C;&#x662F;&#x50A8;&#x5B58;&#x5728;&#x6808;&#x91CC;&#x9762;&#xFF0C;&#x5F15;&#x7528;&#x7C7B;&#x578B;&#x662F;&#x50A8;&#x5B58;&#x5728;&#x5806;">&#x539F;&#x59CB;&#x7C7B;&#x578B;&#x548C;&#x5F15;&#x7528;&#x7C7B;&#x578B;&#x4ED6;&#x4EEC;&#x7684;&#x50A8;&#x5B58;&#x65B9;&#x5F0F;&#x4E0D;&#x4E00;&#x6837;&#xFF0C;&#x539F;&#x59CB;&#x7C7B;&#x578B;&#x7684;&#x503C;&#x662F;&#x50A8;&#x5B58;&#x5728;&#x6808;&#x91CC;&#x9762;&#xFF0C;&#x5F15;&#x7528;&#x7C7B;&#x578B;&#x662F;&#x50A8;&#x5B58;&#x5728;&#x5806;</h5>
<pre><code>1.&#x7B80;&#x5355;&#x6570;&#x636E;&#x7C7B;&#x578B;
    a.&#x5B57;&#x7B26;&#x4E32;(string)
          &#x7528;&#x5F15;&#x53F7;&#x62EC;&#x8D77;&#x6765;&#x7684;&#x5C31;&#x662F;&#x5B57;&#x7B26;&#x4E32;(&#x5F15;&#x53F7;&#x5305;&#x62EC;&#x53CC;&#x5F15;&#x53F7;&#xFF0C;&#x5355;&#x5F15;&#x53F7;);
      &#x6CE8;&#x610F;&#xFF1A;&#x53CC;&#x5F15;&#x53F7;&#x4E0D;&#x80FD;&#x5D4C;&#x5957;&#x53CC;&#x5F15;&#x53F7;&#xFF0C;&#x5355;&#x5F15;&#x53F7;&#x4E5F;&#x4E0D;&#x80FD;&#x5D4C;&#x5957;&#x5355;&#x5F15;&#x53F7;&#xFF0C;
           &#x4F46;&#x662F;&#x53EF;&#x4EE5;&#x4EA4;&#x53C9;&#x5D4C;&#x5957;(&#x5373;&#x5355;&#x5F15;&#x53F7;&#x5D4C;&#x5957;&#x53CC;&#x5F15;&#x53F7;&#xFF0C;&#x53CC;&#x5F15;&#x53F7;&#x5D4C;&#x5957;&#x5355;&#x5F15;&#x53F7;)&#x3002;

      b.&#x6570;&#x503C;&#x7C7B;&#x578B;(Number)
         var num = 123;
         var num = 12.34;
         &#x4E5F;&#x53EF;&#x4EE5;&#x7528;&#x5176;&#x4ED6;&#x8FDB;&#x5236;&#x8868;&#x793A;&#xFF0C;&#x6BD4;&#x5982;16&#x8FDB;&#x5236;&#x7B49;
      *&#x6709;&#x4E09;&#x4E2A;&#x7279;&#x6B8A;&#x503C;
         +Infinity,&#x6B63;&#x65E0;&#x7A77;&#x5927;
          -Infinity,&#x8D1F;&#x65E0;&#x7A77;&#x5927;
         NaN,&#x8868;&#x793A;&#x4E0D;&#x662F;&#x4E00;&#x4E2A;&#x6570;&#x503C;&#xFF0C;&#x4F46;&#x662F;&#x4ED6;&#x7684;&#x7C7B;&#x578B;&#x662F;&#x6570;&#x503C;&#x7C7B;&#x578B;


      isNaN()&#x65B9;&#x6CD5;&#x7528;&#x4E8E;&#x68C0;&#x67E5;&#x5176;&#x53C2;&#x6570;&#x7684;&#x6570;&#x503C;&#x7C7B;&#x578B;&#x662F;&#x5426;&#x4E3A;&#x975E;&#x6570;&#x7EC4;&#x7C7B;&#x578B;


      c.&#x5E03;&#x5C14;&#x503C;(boolean)
         &#x53EA;&#x6709;&#x4E24;&#x4E2A;&#x503C;&#xFF1A;true(&#x771F;),false(&#x5047;)

      d.undefined,&#x8868;&#x793A;&#x53D8;&#x91CF;&#x672A;&#x8D4B;&#x503C;&#x7684;&#x9ED8;&#x8BA4;&#x503C;,&#x4E5F;&#x53EF;&#x4EE5;&#x4EE3;&#x8868;&#x7A7A;

      e.null,&#x7A7A;,&#x8868;&#x793A;&#x5BF9;&#x7A7A;&#x5BF9;&#x8C61;&#x7684;&#x5F15;&#x7528;
         &#x901A;&#x5E38;&#x53EF;&#x4EE5;&#x7528;null&#x6765;&#x6E05;&#x7A7A;&#x6570;&#x636E;

2.&#x590D;&#x6742;&#x6570;&#x636E;&#x7C7B;&#x578B;(&#x5F15;&#x7528;&#x7C7B;&#x578B;)
    1.&#x5BF9;&#x8C61;(object) &#x5C5E;&#x6027;&#x548C;&#x65B9;&#x6CD5;&#x7684;&#x96C6;&#x5408;
        (2)&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x540C;&#x8FC7;  .(&#x70B9;&#x64CD;&#x4F5C;&#x7B26;)&#x6765;&#x8BBF;&#x95EE;&#x5BF9;&#x8C61;&#x4E0A;&#x7684;&#x5C5E;&#x6027;&#x6216;&#x65B9;&#x6CD5;
          (3)&#x600E;&#x4E48;&#x6765;&#x8C03;&#x7528;&#x5BF9;&#x8C61;&#x91CC;&#x9762;&#x7684;&#x65B9;&#x6CD5;&#xFF1F;
            &#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x5BF9;&#x8C61;&#x7684;&#x65B9;&#x6CD5;&#x540D;&#x540E;&#x9762;&#x52A0;&#x5C0F;&#x62EC;&#x53F7;&#x6765;&#x6267;&#x884C;&#x8FD9;&#x4E2A;&#x65B9;&#x6CD5;
        (4)return&#x7528;&#x6765;&#x5B9A;&#x4E49;&#x51FD;&#x6570;&#x7684;&#x8FD4;&#x56DE;&#x503C;

        2.&#x6570;&#x7EC4;(array),&#x662F;&#x6570;&#x636E;&#x96C6;&#x5408;
              (1)&#x6570;&#x7EC4;&#x7684;&#x4E0B;&#x6807;&#x5FD7;(&#x5373;&#x751F;&#x6D3B;&#x4E2D;&#x6240;&#x8BF4;&#x7684;&#x5E8F;&#x5217;&#x53F7;)&#x662F;&#x4ECE;0&#x5F00;&#x59CB;&#xFF0C;&#x6570;&#x7EC4;&#x957F;&#x5EA6;&#x7684;&#x8BA1;&#x7B97;&#x662F;&#x4ECE;1&#x5F00;&#x59CB;&#x8BA1;&#x7B97;
              (2)&#x600E;&#x4E48;&#x83B7;&#x53D6;&#x6570;&#x7EC4;&#x91CC;&#x9762;&#x7684;&#x6570;&#x636E;&#xFF1F;
                  &#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x6570;&#x7EC4;&#x540D;&#x52A0;&#x4E2D;&#x62EC;&#x53F7;&#xFF0C;&#x62EC;&#x53F7;&#x91CC;&#x9762;&#x586B;&#x4E0B;&#x6807;&#x503C;

          3.&#x51FD;&#x6570;(function),&#x5177;&#x6709;&#x4E00;&#x5B9A;&#x529F;&#x80FD;&#x7684;&#x4EE3;&#x7801;&#x5757;
              &#x8BED;&#x6CD5;&#xFF1A;&#x901A;&#x8FC7;&#x5173;&#x952E;&#x5B57;function&#x6765;&#x5B9A;&#x4E49;&#xFF0C;&#x5982;&#x4E0B;&#xFF1A;
                      &#x51FD;&#x6570;&#x540D;&#x548C;&#x53C2;&#x6570;&#x662F;&#x53EF;&#x9009;&#x7684;(&#x53EF;&#x6709;&#x53EF;&#x65E0;)
                  function &#x51FD;&#x6570;&#x540D;(&#x53C2;&#x6570;){
                         &#x4E66;&#x5199;&#x529F;&#x80FD;&#x4EE3;&#x7801;&#x533A;&#x57DF;
                          }
          return&#x7528;&#x6765;&#x5B9A;&#x4E49;&#x51FD;&#x6570;&#x7684;&#x8FD4;&#x56DE;&#x503C;&#xFF0C;&#x4EE5;&#x53CA;&#x7ED3;&#x675F;&#x51FD;&#x6570;&#x7684;&#x6267;&#x884C;

 &#x5224;&#x65AD;&#x6570;&#x636E;&#x7C7B;&#x578B;&#xFF0C;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;typeof()&#x65B9;&#x6CD5;&#x6765;&#x5F97;&#x5230;
</code></pre>
                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="../../md/js/js基础.html" class="navigation navigation-prev " aria-label="Previous page: js介绍"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="../../md/js/js数据类型的转换.html" class="navigation navigation-next " aria-label="Next page: js数据类型的转换"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="../../gitbook/app.js"></script>

    
    <script src="../../gitbook/plugins/gitbook-plugin-search/lunr.min.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-search/search.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-livereload/plugin.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"highlight":{},"search":{"maxIndexSize":1000000},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"livereload":{}};
    gitbook.start(config);
});
</script>

        
    </body>
    
</html>
